home *** CD-ROM | disk | FTP | other *** search
/ Aminet 12 / Aminet 12 (1996)(GTI - Schatztruhe)[!][Jun 1996].iso / Aminet / dev / lang / perl5_bin.lha / lib / perl5 / Amiga / 5.002 / Config.pm
Encoding:
Perl POD Document  |  1996-03-09  |  13.7 KB  |  675 lines

  1. package Config;
  2. use Exporter ();
  3. @ISA = (Exporter);
  4. @EXPORT = qw(%Config);
  5. @EXPORT_OK = qw(myconfig config_sh config_vars);
  6.  
  7. $] == 5.002
  8.   or die "Perl lib version (5.002) doesn't match executable version ($])\n";
  9.  
  10. # This file was created by configpm when Perl was built. Any changes
  11. # made to this file will be lost the next time perl is built.
  12.  
  13. ##
  14. ## This file was produced by running the Configure script. It holds all the
  15. ## definitions figured out by Configure. Should you modify one of these values,
  16. ## do not forget to propagate your changes by running "Configure -der". You may
  17. ## instead choose to run each of the .SH files by yourself, or "Configure -S".
  18. ##
  19. #
  20. ## Configuration time: Thu Feb 29 23:56:29 MET 1996
  21. ## Configured by: amiga
  22. ## Target system: localhost 
  23. #
  24.  
  25. my $config_sh = <<'!END!';
  26. archlibexp='/gnu/lib/perl5/Amiga/5.002'
  27. archname='Amiga'
  28. cc='gcc'
  29. ccflags='-DDEBUGGING'
  30. cppflags='-DDEBUGGING'
  31. dlsrc='dl_none.xs'
  32. dynamic_ext=''
  33. extensions='Fcntl FileHandle Safe GDBM_File SDBM_File'
  34. installarchlib='/gnu/lib/perl5/Amiga/5.002'
  35. installprivlib='/gnu/lib/perl5'
  36. libpth='/gnu/lib'
  37. libs='-lnet -lgdbm -lsdbm -lm -lc'
  38. osname='amigaos'
  39. osvers=''
  40. prefix='/gnu'
  41. privlibexp='/gnu/lib/perl5'
  42. sharpbang='#!'
  43. shsharp='true'
  44. sig_name='ZERO HUP INT QUIT ILL TRAP ABRT EMT FPE KILL BUS SEGV SYS PIPE ALRM TERM URG STOP TSTP CONT CHLD TTIN TTOU IO XCPU XFSZ VTALRM PROF WINCH INFO USR1 USR2 MSG IOT '
  45. so='none'
  46. startsh='#!/bin/sh'
  47. static_ext='Fcntl FileHandle Safe GDBM_File SDBM_File'
  48. Author=''
  49. CONFIG='true'
  50. Date='$Date'
  51. Header=''
  52. Id='$Id'
  53. Locker=''
  54. Log='$Log'
  55. Mcc='Mcc'
  56. PATCHLEVEL='2'
  57. RCSfile='$RCSfile'
  58. Revision='$Revision'
  59. SUBVERSION='0'
  60. Source=''
  61. State=''
  62. afs='false'
  63. alignbytes='2'
  64. aphostname=''
  65. ar='ar'
  66. archlib='/gnu/lib/perl5/Amiga/5.002'
  67. archobjs=''
  68. awk='awk'
  69. baserev='5.0'
  70. bash=''
  71. bin='/gnu/bin'
  72. binexp='/gnu/bin'
  73. bison=''
  74. byacc='byacc'
  75. byteorder='4321'
  76. c=''
  77. castflags='0'
  78. cat='cat'
  79. cccdlflags=''
  80. ccdlflags=''
  81. cf_by='amiga'
  82. cf_email='amiga@localhost.nowhere'
  83. cf_time='Thu Feb 29 23:56:29 MET 1996'
  84. chgrp=''
  85. chmod='chmod'
  86. chown=''
  87. clocktype='clock_t'
  88. comm='comm'
  89. compress=''
  90. contains='grep'
  91. cp='cp'
  92. cpio=''
  93. cpp='cpp'
  94. cpp_stuff='42'
  95. cpplast='-'
  96. cppminus='-'
  97. cpprun='gcc -E'
  98. cppstdin='gcc -E'
  99. cryptlib=''
  100. csh=''
  101. d_Gconvert='sprintf((b),"%.*g",(n),(x))'
  102. d_access='define'
  103. d_alarm='define'
  104. d_archlib='define'
  105. d_attribut='define'
  106. d_bcmp='define'
  107. d_bcopy='define'
  108. d_bsd='define'
  109. d_bsdpgrp='undef'
  110. d_bzero='define'
  111. d_casti32='define'
  112. d_castneg='define'
  113. d_charvspr='undef'
  114. d_chown='define'
  115. d_chroot='undef'
  116. d_chsize='undef'
  117. d_closedir='define'
  118. d_const='define'
  119. d_crypt='define'
  120. d_csh='undef'
  121. d_cuserid='define'
  122. d_dbl_dig='define'
  123. d_difftime='define'
  124. d_dirnamlen='define'
  125. d_dlerror='undef'
  126. d_dlopen='undef'
  127. d_dlsymun='undef'
  128. d_dosuid='undef'
  129. d_dup2='define'
  130. d_eofnblk='define'
  131. d_eunice='undef'
  132. d_fchmod='define'
  133. d_fchown='undef'
  134. d_fcntl='define'
  135. d_fd_macros='define'
  136. d_fd_set='define'
  137. d_fds_bits='define'
  138. d_fgetpos='define'
  139. d_flexfnam='define'
  140. d_flock='define'
  141. d_fork='undef'
  142. d_fpathconf='define'
  143. d_fsetpos='define'
  144. d_getgrps='define'
  145. d_gethent='undef'
  146. d_gethname='undef'
  147. d_getlogin='define'
  148. d_getpgrp2='undef'
  149. d_getpgrp='define'
  150. d_getppid='define'
  151. d_getprior='define'
  152. d_htonl='define'
  153. d_index='undef'
  154. d_isascii='define'
  155. d_killpg='define'
  156. d_link='define'
  157. d_locconv='undef'
  158. d_lockf='undef'
  159. d_lstat='define'
  160. d_mblen='define'
  161. d_mbstowcs='define'
  162. d_mbtowc='define'
  163. d_memcmp='define'
  164. d_memcpy='define'
  165. d_memmove='define'
  166. d_memset='define'
  167. d_mkdir='define'
  168. d_mkfifo='define'
  169. d_mktime='define'
  170. d_msg='undef'
  171. d_msgctl='undef'
  172. d_msgget='undef'
  173. d_msgrcv='undef'
  174. d_msgsnd='undef'
  175. d_mymalloc='undef'
  176. d_nice='define'
  177. d_oldarchlib='undef'
  178. d_oldsock='undef'
  179. d_open3='define'
  180. d_pathconf='define'
  181. d_pause='define'
  182. d_phostname='undef'
  183. d_pipe='define'
  184. d_poll='undef'
  185. d_portable='define'
  186. d_pwage='undef'
  187. d_pwchange='define'
  188. d_pwclass='define'
  189. d_pwcomment='undef'
  190. d_pwexpire='define'
  191. d_pwquota='undef'
  192. d_readdir='define'
  193. d_readlink='define'
  194. d_rename='define'
  195. d_rewinddir='define'
  196. d_rmdir='define'
  197. d_safebcpy='define'
  198. d_safemcpy='undef'
  199. d_seekdir='define'
  200. d_select='define'
  201. d_sem='undef'
  202. d_semctl='undef'
  203. d_semget='undef'
  204. d_semop='undef'
  205. d_setegid='undef'
  206. d_seteuid='undef'
  207. d_setlinebuf='define'
  208. d_setlocale='undef'
  209. d_setpgid='undef'
  210. d_setpgrp2='undef'
  211. d_setpgrp='define'
  212. d_setprior='define'
  213. d_setregid='undef'
  214. d_setresgid='undef'
  215. d_setresuid='undef'
  216. d_setreuid='undef'
  217. d_setrgid='undef'
  218. d_setruid='undef'
  219. d_setsid='undef'
  220. d_shm='undef'
  221. d_shmat='undef'
  222. d_shmatprototype='undef'
  223. d_shmctl='undef'
  224. d_shmdt='undef'
  225. d_shmget='undef'
  226. d_shrplib='undef'
  227. d_sigaction='define'
  228. d_sigintrp=''
  229. d_sigsetjmp='undef'
  230. d_sigvec='define'
  231. d_sigvectr='undef'
  232. d_socket='define'
  233. d_sockpair='undef'
  234. d_statblks='define'
  235. d_stdio_cnt_lval='undef'
  236. d_stdio_ptr_lval='undef'
  237. d_stdiobase='undef'
  238. d_stdstdio='undef'
  239. d_strchr='define'
  240. d_strcoll='define'
  241. d_strctcpy='define'
  242. d_strerrm='strerror(e)'
  243. d_strerror='define'
  244. d_strxfrm='define'
  245. d_suidsafe='undef'
  246. d_symlink='define'
  247. d_syscall='undef'
  248. d_sysconf='define'
  249. d_sysernlst=''
  250. d_syserrlst='define'
  251. d_system='define'
  252. d_tcgetpgrp='define'
  253. d_tcsetpgrp='define'
  254. d_telldir='define'
  255. d_time='define'
  256. d_times='define'
  257. d_truncate='define'
  258. d_tzname='define'
  259. d_umask='define'
  260. d_uname='define'
  261. d_vfork='define'
  262. d_void_closedir='undef'
  263. d_voidsig='define'
  264. d_voidtty=''
  265. d_volatile='define'
  266. d_vprintf='define'
  267. d_wait4='define'
  268. d_waitpid='define'
  269. d_wcstombs='define'
  270. d_wctomb='define'
  271. d_xenix='undef'
  272. date='date'
  273. db_hashtype='int'
  274. db_prefixtype='int'
  275. defvoidused='15'
  276. direntrytype='struct dirent'
  277. dlext='none'
  278. eagain='EAGAIN'
  279. echo='echo'
  280. egrep='egrep'
  281. emacs=''
  282. eunicefix=':'
  283. exe_ext=''
  284. expr='expr'
  285. find='find'
  286. firstmakefile='GNUmakefile'
  287. flex=''
  288. fpostype='fpos_t'
  289. freetype='void'
  290. full_csh=''
  291. full_sed='/bin/sed'
  292. gcc=''
  293. gccversion='2.7.2'
  294. gidtype='gid_t'
  295. glibpth='/usr/shlib  /lib/pa1.1 /usr/lib/large /lib /usr/lib /usr/lib/386 /lib/386 /lib/large /usr/lib/small /lib/small /usr/ccs/lib /usr/ucblib /usr/shlib '
  296. grep='grep'
  297. groupcat=''
  298. groupstype='int*'
  299. h_fcntl='false'
  300. h_sysfile='true'
  301. hint='previous'
  302. hostcat=''
  303. huge=''
  304. i_bsdioctl=''
  305. i_db='define'
  306. i_dbm='define'
  307. i_dirent='define'
  308. i_dld='undef'
  309. i_dlfcn='undef'
  310. i_fcntl='undef'
  311. i_float='define'
  312. i_gdbm='define'
  313. i_grp='define'
  314. i_limits='define'
  315. i_locale='define'
  316. i_malloc='undef'
  317. i_math='define'
  318. i_memory='undef'
  319. i_ndbm='define'
  320. i_neterrno='undef'
  321. i_niin='define'
  322. i_pwd='define'
  323. i_rpcsvcdbm='undef'
  324. i_sgtty='undef'
  325. i_stdarg='define'
  326. i_stddef='define'
  327. i_stdlib='define'
  328. i_string='define'
  329. i_sysdir='define'
  330. i_sysfile='define'
  331. i_sysfilio='define'
  332. i_sysin='undef'
  333. i_sysioctl='define'
  334. i_sysndir='undef'
  335. i_sysparam='define'
  336. i_sysselct='undef'
  337. i_syssockio=''
  338. i_sysstat='define'
  339. i_systime='define'
  340. i_systimek='undef'
  341. i_systimes='define'
  342. i_systypes='define'
  343. i_sysun='define'
  344. i_termio='undef'
  345. i_termios='define'
  346. i_time='undef'
  347. i_unistd='define'
  348. i_utime='define'
  349. i_varargs='undef'
  350. i_varhdr='stdarg.h'
  351. i_vfork='undef'
  352. incpath=''
  353. inews=''
  354. installbin='/gnu/bin'
  355. installman1dir=''
  356. installman3dir=''
  357. installscript='/gnu/bin'
  358. installsitearch='/gnu/lib/perl5/site_perl/Amiga'
  359. installsitelib='/gnu/lib/perl5/site_perl'
  360. intsize='4'
  361. known_extensions='DB_File Fcntl FileHandle GDBM_File NDBM_File ODBM_File POSIX SDBM_File Safe Socket'
  362. ksh=''
  363. large=''
  364. ld='ld'
  365. lddlflags=''
  366. ldflags='-s'
  367. less='less'
  368. lib_ext='.a'
  369. libc='/gnu/lib/libc.a'
  370. libswanted='net socket inet nsl nm ndbm gdbm dbm db malloc dl dld ld sun m c cposix posix ndir dir crypt ucb bsd BSD PW x'
  371. line='line'
  372. lint=''
  373. lkflags=''
  374. ln='ln'
  375. lns='/bin/ln -s'
  376. locincpth='/usr/local/include /opt/local/include /usr/gnu/include /opt/gnu/include /usr/GNU/include /opt/GNU/include'
  377. loclibpth='/usr/local/lib /opt/local/lib /usr/gnu/lib /opt/gnu/lib /usr/GNU/lib /opt/GNU/lib'
  378. lp=''
  379. lpr=''
  380. ls='ls'
  381. lseektype='off_t'
  382. mail=''
  383. mailx=''
  384. make=''
  385. mallocobj=''
  386. mallocsrc=''
  387. malloctype='void *'
  388. man1dir=' '
  389. man1direxp=''
  390. man1ext='0'
  391. man3dir=' '
  392. man3direxp=''
  393. man3ext='0'
  394. medium=''
  395. mips=''
  396. mips_type=''
  397. mkdir='mkdir'
  398. models='none'
  399. modetype='mode_t'
  400. more='more'
  401. mv=''
  402. myarchname='amigaos'
  403. mydomain='.nowhere'
  404. myhostname='localhost'
  405. myuname='localhost '
  406. n='-n'
  407. nm_opt=''
  408. nm_so_opt=''
  409. nroff='nroff'
  410. o_nonblock='O_NONBLOCK'
  411. obj_ext='.o'
  412. oldarchlib=''
  413. oldarchlibexp=''
  414. optimize='-O'
  415. orderlib='false'
  416. package='perl5'
  417. pager='/bin/less'
  418. passcat=''
  419. patchlevel='2'
  420. path_sep=':'
  421. perl='perl'
  422. perladmin='amiga@localhost.nowhere'
  423. perlpath='/gnu/bin/perl'
  424. pg='pg'
  425. phostname='hostname'
  426. plibpth=''
  427. pmake=''
  428. pr=''
  429. prefixexp='/gnu'
  430. privlib='/gnu/lib/perl5'
  431. prototype='define'
  432. randbits='31'
  433. ranlib=':'
  434. rd_nodata='-1'
  435. rm='rm'
  436. rmail=''
  437. runnm='true'
  438. scriptdir='/gnu/bin'
  439. scriptdirexp='/gnu/bin'
  440. sed='sed'
  441. selecttype='fd_set *'
  442. sendmail='sendmail'
  443. sh=''
  444. shar=''
  445. shmattype=''
  446. shrpdir='none'
  447. sig_num='0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 6 '
  448. signal_t='void'
  449. sitearch='/gnu/lib/perl5/site_perl/Amiga'
  450. sitearchexp='/gnu/lib/perl5/site_perl/Amiga'
  451. sitelib='/gnu/lib/perl5/site_perl'
  452. sitelibexp='/gnu/lib/perl5/site_perl'
  453. sizetype='size_t'
  454. sleep=''
  455. smail=''
  456. small=''
  457. sockethdr=''
  458. socketlib=''
  459. sort='sort'
  460. spackage='Perl5'
  461. spitshell='cat'
  462. split=''
  463. ssizetype='int'
  464. startperl='#!/gnu/bin/perl'
  465. stdchar='char'
  466. stdio_base='((fp)->_base)'
  467. stdio_bufsiz='((fp)->_cnt + (fp)->_ptr - (fp)->_base)'
  468. stdio_cnt='((fp)->_cnt)'
  469. stdio_ptr='((fp)->_ptr)'
  470. strings='/gnu/include/string.h'
  471. submit=''
  472. sysman='/gnu/man/man1'
  473. tail=''
  474. tar=''
  475. tbl=''
  476. test='test'
  477. timeincl='/gnu/include/sys/time.h '
  478. timetype='time_t'
  479. touch='touch'
  480. tr='tr'
  481. troff=''
  482. uidtype='uid_t'
  483. uname='uname'
  484. uniq='uniq'
  485. usedl='undef'
  486. usemymalloc='n'
  487. usenm='true'
  488. useposix='true'
  489. usesafe='true'
  490. usevfork='true'
  491. usrinc='/gnu/include'
  492. uuname=''
  493. vi=''
  494. voidflags='15'
  495. xlibpth='/usr/lib/386 /lib/386'
  496. zcat=''
  497. !END!
  498.  
  499. my $summary = <<'!END!';
  500. Summary of my $package ($baserev patchlevel $PATCHLEVEL) configuration:
  501.   Platform:
  502.     osname=$osname, osver=$osvers, archname=$archname
  503.     uname='$myuname'
  504.     hint=$hint, useposix=$useposix 
  505.   Compiler:
  506.     cc='$cc', optimize='$optimize', gccversion=$gccversion
  507.     cppflags='$cppflags'
  508.     ccflags ='$ccflags'
  509.     stdchar='$stdchar', d_stdstdio=$d_stdstdio, usevfork=$usevfork
  510.     voidflags=$voidflags, castflags=$castflags, d_casti32=$d_casti32, d_castneg=$d_castneg
  511.     intsize=$intsize, alignbytes=$alignbytes, usemymalloc=$usemymalloc, randbits=$randbits
  512.   Linker and Libraries:
  513.     ld='$ld', ldflags ='$ldflags'
  514.     libpth=$libpth
  515.     libs=$libs
  516.     libc=$libc, so=$so
  517.   Dynamic Linking:
  518.     dlsrc=$dlsrc, dlext=$dlext, d_dlsymun=$d_dlsymun, ccdlflags='$ccdlflags'
  519.     cccdlflags='$cccdlflags', lddlflags='$lddlflags'
  520.  
  521. !END!
  522. my $summary_expanded = 0;
  523.  
  524. sub myconfig {
  525.     return $summary if $summary_expanded;
  526.     $summary =~ s/\$(\w+)/$Config{$1}/ge;
  527.     $summary_expanded = 1;
  528.     $summary;
  529. }
  530.  
  531. tie %Config, Config;
  532. sub TIEHASH { bless {} }
  533. sub FETCH { 
  534.     # check for cached value (which maybe undef so we use exists not defined)
  535.     return $_[0]->{$_[1]} if (exists $_[0]->{$_[1]});
  536.  
  537.     my($value); # search for the item in the big $config_sh string
  538.     return undef unless (($value) = $config_sh =~ m/^$_[1]='(.*)'\s*$/m);
  539.  
  540.     $value = undef if $value eq 'undef'; # So we can say "if $Config{'foo'}".
  541.     $_[0]->{$_[1]} = $value; # cache it
  542.     return $value;
  543. }
  544.  
  545. my $prevpos = 0;
  546.  
  547. sub FIRSTKEY {
  548.     $prevpos = 0;
  549.     my($key) = $config_sh =~ m/^(.*?)=/;
  550.     $key;
  551. }
  552.  
  553. sub NEXTKEY {
  554.     my $pos = index($config_sh, "\n", $prevpos) + 1;
  555.     my $len = index($config_sh, "=", $pos) - $pos;
  556.     $prevpos = $pos;
  557.     $len > 0 ? substr($config_sh, $pos, $len) : undef;
  558. }
  559.  
  560. sub EXISTS { 
  561.      exists($_[0]->{$_[1]})  or  $config_sh =~ m/^$_[1]=/m; 
  562. }
  563.  
  564. sub STORE  { die "\%Config::Config is read-only\n" }
  565. sub DELETE { &STORE }
  566. sub CLEAR  { &STORE }
  567.  
  568.  
  569. sub config_sh {
  570.     $config_sh
  571. }
  572. sub config_vars {
  573.     foreach(@_){
  574.     my $v=(exists $Config{$_}) ? $Config{$_} : 'UNKNOWN';
  575.     $v='undef' unless defined $v;
  576.     print "$_='$v';\n";
  577.     }
  578. }
  579.  
  580. 1;
  581. __END__
  582.  
  583. =head1 NAME
  584.  
  585. Config - access Perl configuration information
  586.  
  587. =head1 SYNOPSIS
  588.  
  589.     use Config;
  590.     if ($Config{'cc'} =~ /gcc/) {
  591.     print "built by gcc\n";
  592.     } 
  593.  
  594.     use Config qw(myconfig config_sh config_vars);
  595.  
  596.     print myconfig();
  597.  
  598.     print config_sh();
  599.  
  600.     config_vars(qw(osname archname));
  601.  
  602.  
  603. =head1 DESCRIPTION
  604.  
  605. The Config module contains all the information that was available to
  606. the C<Configure> program at Perl build time (over 900 values).
  607.  
  608. Shell variables from the F<config.sh> file (written by Configure) are
  609. stored in the readonly-variable C<%Config>, indexed by their names.
  610.  
  611. Values stored in config.sh as 'undef' are returned as undefined
  612. values.  The perl C<exists> function can be used to check is a
  613. named variable exists.
  614.  
  615. =over 4
  616.  
  617. =item myconfig()
  618.  
  619. Returns a textual summary of the major perl configuration values.
  620. See also C<-V> in L<perlrun/Switches>.
  621.  
  622. =item config_sh()
  623.  
  624. Returns the entire perl configuration information in the form of the
  625. original config.sh shell variable assignment script.
  626.  
  627. =item config_vars(@names)
  628.  
  629. Prints to STDOUT the values of the named configuration variable. Each is
  630. printed on a separate line in the form:
  631.  
  632.   name='value';
  633.  
  634. Names which are unknown are output as C<name='UNKNOWN';>.
  635. See also C<-V:name> in L<perlrun/Switches>.
  636.  
  637. =back
  638.  
  639. =head1 EXAMPLE
  640.  
  641. Here's a more sophisticated example of using %Config:
  642.  
  643.     use Config;
  644.  
  645.     defined $Config{sig_name} || die "No sigs?";
  646.     foreach $name (split(' ', $Config{sig_name})) {
  647.     $signo{$name} = $i;
  648.     $signame[$i] = $name;
  649.     $i++;
  650.     }   
  651.  
  652.     print "signal #17 = $signame[17]\n";
  653.     if ($signo{ALRM}) { 
  654.     print "SIGALRM is $signo{ALRM}\n";
  655.     }   
  656.  
  657. =head1 WARNING
  658.  
  659. Because this information is not stored within the perl executable
  660. itself it is possible (but unlikely) that the information does not
  661. relate to the actual perl binary which is being used to access it.
  662.  
  663. The Config module is installed into the architecture and version
  664. specific library directory ($Config{installarchlib}) and it checks the
  665. perl version number when loaded.
  666.  
  667. =head1 NOTE
  668.  
  669. This module contains a good example of how to use tie to implement a
  670. cache and an example of how to make a tied variable readonly to those
  671. outside of it.
  672.  
  673. =cut
  674.  
  675.